<?php

//检测数组
function _checkInarray($list, $modulevalue = '', $limitvalue = '') {
    $res = 0;
    if (is_array($list[0])) {
        foreach ($list as $k => $item) {
            if ($modulevalue && $limitvalue) {
                if (in_array($modulevalue, $item, TRUE) && in_array($limitvalue, $item, TRUE)) {
                    $res++;
                }
                continue;
            } elseif ($modulevalue) {
                if (in_array($modulevalue, $item, TRUE)) {
                    $res++;
                }
                continue;
            }
        }
    } else {
        if (in_array($modulevalue, $list)) {
            $res++;
        }
    }
    return $res;
}

//数据层级化，
function _findChildren($list, $p_id) {
    $r = array();
    foreach ($list as $id => $item) {
        if ($item['parentid'] == $p_id) {
            $length = count($r);
            $r[$length] = $item;
            if (@$t = _findChildren($list, $item['sysmoduleid'])) {
                $r[$length]['children'] = $t;
            }
        }
    }
    return $r;
}

function substr_CN($str,$mylen){                                                                                                                                        
$len=strlen($str);
$content='';
$count=0;
for($i=0;$i<$len;$i++){
   if(ord(substr($str,$i,1))>127){
    $content.=substr($str,$i,2);
    $i++;
   }else{
    $content.=substr($str,$i,1);
   }
   if(++$count==$mylen){
    break;
   }
}
echo $content;
}
